<?php
class InsultBuilder {
	private $targetUrl;
	private $firstArgument;
	public function __construct() {
		$this->targetUrl = "insulter.php";
		$this->firstArgument = false;
	}
	public function setTitle($title) {
		$this->appendToUrl ( "title", $title );
		return $this;
	}
	public function setMessage($message) {
		$this->appendToUrl ( "message", $message );
		return $this;
	}
	public function setPicture($fileName) {
		$this->appendToUrl ( "pic", $fileName );
		return $this;
	}
	public function setSource($source) {
		$this->appendToUrl ( "source", $source );
		return $this;
	}
	private function appendToUrl($field, $append) {
		if ($this->firstArgument === false) {
			$this->targetUrl = $this->targetUrl . "?" . $field . "=" . $append;
			$this->firstArgument = true;
		} else {
			$this->targetUrl = $this->targetUrl . "&" . $field . "=" . $append;
		}
	}
	public function build() {
		return $this->targetUrl;
	}
}

?>